package tw.edu.tku.im.maze;
import org.json.JSONException;
import org.json.JSONObject;


public class AddRoomRepParser extends PacketParser {
   public static AddRoomRepParser INSTANCE = new AddRoomRepParser();
   
   private AddRoomRepParser() { }

   @Override
   public AddRoomRep parse(JSONObject jsonObj) throws JSONException {
      JSONObject result = jsonObj.getJSONObject("result");
      int state = result.getInt("state");
      if(result.isNull("roomID")) {
         return new AddRoomRep(state);
      }
      int roomID = result.getInt("roomID");
      return new AddRoomRep(state, roomID);    
   }

   @Override
   public String acceptName() {
      return "addRoomResponse";
   }

}
